<?php
include ("class.php"); 
include ("db/db_connect.php"); 

include"includes/functions.php";
include"includes/biblio_js.php";

if ($_GET["act"]=="cad"){

$id=$_POST["txtid"];
$nome=$_POST["txtnome"];

	$sql="update tab_curso set curso='".$nome."' where co_curso=".$id."";
	mysql_query($sql, $db_conn)or die("<script>\n alert('Erro ao Atualizar!'); \n history.back();\n</script>\n");

/*
######################	
Inicio - Tabela de Log
######################	
*/
session_start();

$date=getdate();
$data= $date["year"]."-".$date["mon"]."-".$date["mday"]." ".$date["hours"].":".$date["minutes"].":".$date["seconds"];
$usuario=$_SESSION['nomeAdmin'];
$id_usuario=$_SESSION['idAdmin'];
$obs=" SQL: ".str_replace("'","\"",$sql)." ";

	$sql1="insert into tab_log(id_usuario, usuario, date, observacao) values($id_usuario,'$usuario','$data','$obs')";
	mysql_query($sql1, $db_conn);
	unset($sql1);
/*
######################	
FIM - Tabela de Log
######################	
*/			
	unset($sql);

	echo "<script>\n alert('Atualizado com sucesso!');\nwindow.opener.location='cursos.php';\nwindow.close();\n</script>\n";

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/estagio.css" rel="stylesheet" type="text/css">
<title><?php titulo(); ?></title>
<style type="text/css">
<!--
body {
	background-color: #e7e7e7;
}
#Layer1 {
	position:absolute;
	left:0px;
	top:0px;
	width:44px;
	height:60px;
	z-index:1;
}
-->
</style></head>

<body>
<div id="Layer1">
  <table width="241" height="69" cellpadding="0" cellspacing="0">
   <tr>
     <td height="18" colspan="2" bgcolor="#006633"><div align="left"><font color="#e7e7e7"  face="Verdana" size="2"><b>&nbsp;</b></font><font color="#e7e7e7"  face="Verdana" size="1"><b>Cursos</b></font></div></td>
  </tr>
  <?php
$id=$_GET["id"];
$sql2="select * from tab_curso where co_curso=$id";
$resp2=mysql_query($sql2,$db_conn);
$row=mysql_fetch_array($resp2);

?>
   <form id="form_cursos" name="form_cursos" method="post" action="atualizar_area.php?act=cad">
   <input type="hidden" name="txtid" id="txtid" value="<?php echo  $id;?>">
             <tr>
               <td width="15%" height="21" valign="middle" class="txtDescCampoInscricao">Nome:</td>
               <td width="85%" valign="bottom"><input name="txtnome" type="text" id="txtnome" size="30" value="<?php echo  $row["curso"];?>"/></td>
      </tr>
    <tr>
      <td height="28" colspan="2" align="left" valign="bottom"><div align="center">
        <input type="button" name="Button" value="Atualizar" onclick="JavaScript: if (document.getElementById('txtnome').value =='')
																						{ alert('Favor preencher todos os campos!'); } else { document.form_cursos.submit(); }"/>
      </div></td>
    </tr>
    </form>
  </table>
</div>
</body>
</html>
